{extend name="base"/}
{block name="content"}
<div id="header-frame">
    {include file="public:top" /}
    <script type='text/javascript' src='__STATIC__/admin/uploadajax/js/jquery-2.0.3.min.js'></script>
    <script type='text/javascript' src='__STATIC__/admin/uploadajax/js/jquery.form.js'></script>
    <link href="__STATIC__/admin/uploadajax/css/style.css" type="text/css" rel="stylesheet"/>
    <link href="__STATIC__/admin/css/product_index.css" type="text/css" rel="stylesheet"/>
</div>
<div id="frame-body">
    <div id="menu-frame" style="width: 100%;float: left;">
        {include file="public:menu" /}


    </div>
    <div id="main-frame" style="float: left;">
        <div id="dcMain" style="margin-left: 20px;width: 1682px;">
            <div id="urHere">DouPHP 管理中心<b>></b><strong>商品分类</strong> </div>   <div class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
            <h3><a href="{:url('admin/product/add_goods')}" class="actionBtn add">添加商品</a>商品分类</h3>
            <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                <tr>
                    <th  align="center">商品名称</th>
                    <th align="center">价格</th>
                    <th  align="center">库存</th>
                    <th  align="center">商品规格</th>
                    <th  align="center">总销量</th>
                    <th align="center">上下架</th>
                    <th align="center">发货信息</th>
                    <th  align="center">发布时间</th>
                    <th  align="center">操作</th>
                </tr>
                {foreach name="allData" item="vo"}
                <tr>
                    <td align="center">{$vo['products_name']}</td>
                    <td align="center">{$vo['products_sellingprice']}</td>
                    <td align="center">{$vo['products_stock']}</td>
                    <td align="center" class="buttonOn"><a href="{:url('admin/product/specific')}?pid={$vo['products_id']}">编辑规格</a></td>
                    <td align="center">6666</td>
                    <td align="center" class="buttonOn">{if condition="$vo['products_states']==1"}<a onclick="reasonFunShow({$vo['products_id']})">下架{else /}<a onclick="FaShow({$vo['products_id']})">发布</a> {/if}</td>
                    <td align="center" class="buttonOn">{if condition="$vo['place_id']== true"}<a href="{:url('admin/product/place')}?pid={$vo['place_id']}">查看</a>{else /} <a href="{:url('admin/product/add_place')}?pid={$vo['products_id']}">添加</a>{/if}</td>
                    <td align="center"> {$vo['releasetime']|date="Y-m-d H:i",###}</td>
                    <td align="center" class="buttonOn"><a href="{:url('admin/product/edit')}?id={$vo['products_id']}">编辑</a></td>
                </tr>
                {/foreach}
            </table>
        </div>
        </div>
        <div class="reasonBox">
            <div><textarea placeholder="请填写下架原因" id="reasonFrom"></textarea></div>
            <div  class="buttonOn"><a onclick="reasonPost()">确定</a><a onclick="reasonFunHide()">取消</a></div>
        </div>
        <div class="clear"></div>
        <script type="text/javascript">
            //提交下架原因
            function reasonPost()
            {
                var id=$(".reasonBox").attr("_id")
                var form=$("#reasonFrom").val()
                var url="{:url('admin/product/reasonPost')}";
                var success_url="{:url('admin/product/index')}";
                $.post(url,{'id':id,'form':form},function(result){
                    if(result.valid=='4')
                    {
                        dialog.success(result.msg,success_url);
                    }else
                    {
                        dialog.error(result.msg);
                    }
                })


            }
            //发布
            function FaShow(id)
            {
                var url="{:url('admin/product/faShow')}";
                var success_url="{:url('admin/product/index')}";
                $.post(url,{'id':id},function(result){
                    if(result.valid=='4')
                    {
                        dialog.success(result.msg,success_url);
                    }else
                    {
                        dialog.error(result.msg);
                    }
                })
            }
            //删除分类
            function protypes_dele(message, id) {
                layer.open({
                    content : message,

                    icon:3,
                    btn : ['是','否'],
                    yes : function(){
                        var url="{:url('admin/product/protype_dele')}";
                        var success_url="{:url('admin/product/index')}";
                        $.post(url,{'protype_id':id},function(result){
                            if(result.status=='4')
                            {
                                dialog.success(result.message,success_url);
                            }else
                            {
                                dialog.error(result.message);
                            }
                        })
                    }
                });
            }
            function reasonFunShow(id){
                $(".reasonBox").attr("_id",id)
                $(".reasonBox").show()
            }
            function reasonFunHide(){
                $(".reasonBox").hide()
            }
        </script>
        {/block}